﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UpdatedHomeMaker
{
    class dayThingArray : System.Collections.CollectionBase
    {
        private System.Windows.Forms.Form HostForm;
        public dayThingArray(System.Windows.Forms.Form host)
        {
           HostForm = host;
           this.AddNewButton();
        }
        public DayThing AddNewButton()
        {
            // Create a new instance of the Button class.
            DayThing day = new DayThing();
            // Add the button to the collection's internal list.
            this.List.Add(day);
            // Add the button to the controls collection of the form 
            // referenced by the HostForm field.
            HostForm.Controls.Add(day);
            // Set intial properties for the button object.
            day.Top = Count * 25;
            day.Left = 100;
            day.Tag = this.Count;
            day.Visible = true;
            return day;
        }
        public System.Windows.Forms.Button this[int Index]
        {
            get
            {
                return (System.Windows.Forms.Button)this.List[Index];
            }
        }
        public void Remove()
        {
            // Check to be sure there is a button to remove.
            if (this.Count > 0)
            {
                // Remove the last button added to the array from the host form 
                // controls collection. Note the use of the indexer in accessing 
                // the array.
                HostForm.Controls.Remove(this[this.Count - 1]);
                this.List.RemoveAt(this.Count - 1);
            }
        }
    }
}
